﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Persistence;
using Persistence.Dao;
namespace web
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Domain.User user = Singleton<UserDao>.Instance.GetModelWhenLogin(username.Value.Trim(), password.Value.Trim());
            if (user != null)
            {
                Session["user"] = user;
                if (Request["from"] != null)
                {
                    Response.Redirect(Request["from"]);
                }
                else if (Request.ServerVariables[""] != null)
                {
                    Response.Redirect(Request.ServerVariables[""]);
                }
                else
                {
                    Response.Redirect("/default.aspx");
                }
            }
        }
    }
}
